<template>
    <div class="box">
        <el-card>
            <div class="card">
                <el-checkbox class="check-btn" v-model="checked"></el-checkbox>
                <el-row style="margin-bottom:10px;">
                    <el-col :span="8">
                        <img class="bycicle-img" :src="infoByc.pic" alt="">
                    </el-col>
                    <el-col :span="16">
                        <div class="msg">
                            <span>编号:</span>
                            <a class="bycicle-id">{{ infoByc.c_bikeno }}</a><a class="btn-copy">复制</a>
                        </div>
                        <div>
                            <el-progress class="pro" :text-inside="true" :stroke-width="26"
                                :percentage="parseFloat(infoByc.power)"></el-progress>
                            <el-progress class="pro" :text-inside="true" :stroke-width="24"
                                :percentage="parseFloat(infoByc.mileage)" status="success" 
                                :show-text="true">6511</el-progress>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="16">
                        <div class="info1">
                            <span>单车平台: {{ infoByc.bike_plateform }}</span>
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <el-button style="float:right;" type="danger" size="small" @click="delBike(infoByc.c_bikeno)"
                            plain>返厂维护</el-button>
                    </el-col>
                </el-row>
            </div>
        </el-card>

    </div>
</template>

<script>
import API from "@/utils/request"
export default {
    emits: ["calledDeleting"],
    props: {
        infoByc: {
            id: {
                type: String,
                default: ''
            },
            plateName: {
                type: String,
                default: ''
            },
            kilomiter: {
                type: Number,
                default: 0
            },
            power: {
                type: Number,
                default: 0
            },
            avatar: {
                type: String,
                default: ''
            },
            isChecked: {
                type: Boolean,
                default: false
            }
        }
    },
    data() {
        return {
            checked: false,
            deleteParam: {
                bikeId: ""
            }
        }
    },
    methods: {
        delBike(data) {
            this.deleteParam.bikeId = data;

            API.delBike(this.deleteParam, ((res) => {
                console.log(res);
                if (res.code === 200) {
                    this.$message({
                        message: '删除成功',
                        type: 'success'
                    });
                    this.$emit("calledDeleting");
                } else {
                    this.$message({
                        message: '网络不佳请稍后再试',
                        type: 'error'
                    })
                }
            }))
        }
    }
}
</script>

<style scoped>
.card {
    padding: 5px;
}

.info1 {
    text-align: left;
}

.info2 {
    text-align: left;
}

.card .check-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    scale: 1.3;
}

.bycicle-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
}

.pro {
    margin-top: 10px;
}


.bycicle-id {
    margin-left: 10px;
}

.btn-copy {
    margin-left: 10px;
    text-decoration: none;
    color: rgb(0, 76, 255);
    cursor: pointer;
}

.msg {
    margin-bottom: 10px;
    text-align: left;
}

.box {
    position: relative;
    display: inline-block;
    width: 400px;
}
</style>